<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<title>忘记密码</title>
	<meta name="viewport"
		content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="stylesheet" href="css/mui.min.css" />
	<!-- build:css css/app.css -->
	<link rel="stylesheet" href="css/common.css">
	<link rel="stylesheet" href="css/base.css" />
	<!-- endbuild -->
	<style type="text/css">
		body,
		.mui-content {
			background: #ffffff;
		}

		.get-code {
			bottom: 14px;
		}
	</style>
</head>

<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">忘记密码</h1>
	</header>
	<div class="mui-content">
		<div class="mui-slider-group">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<input type="text" class="mui-input-clear phone" placeholder="请输入手机号" maxlength="18">
				</div>
			</form>
			<form class="mui-input-group">
				<div class="mui-input-row">
					<input type="text" class="code" placeholder="请输入验证码" maxlength="6">
					<span id="getCode" class="get-code">获取验证码</span>
					<span id="codeDate" class="get-code mui-hidden">180s</span>
				</div>
			</form>
			<form class="mui-input-group">
				<div class="mui-input-row">
					<input type="password" class="mui-input-clear password" placeholder="请输入新密码" maxlength="18">
				</div>
			</form>
		</div>
		<button type="button" id="login" data-loading-text="提交中"
			class="button button-red mui-btn mui-btn-block">保存</button>
	</div>
</body>
<script src="js/mui.min.js"></script>
<script src="js/zepto.min.js"></script>
<!-- build:js js/app.js -->
<script src="js/api.js"></script>
<script src="js/tools.js"></script>
<!-- endbuild -->
<script type="text/javascript">
	var phone = $('.phone');
	var password = $('.password');
	var code = $('.code');

	// 获取验证码
	$('#getCode').on('tap', function () {
		window.getCode(phone.val(), 3)
	})

	$('#login').on('tap', function () {
		if (isPhone(phone.val()) == false) {
			return false
		}
		if (isPassword(password.val()) == false) {
			return false
		}
		if (code.val() == '') {
			mui.toast('请输入验证码！');
			return false
		}
		mui.ajax(config.ME_API + 'h5/h5ForgetPassword', {
			data: {
				phone: phone.val(),
				password: password.val(),
				msg: code.val()
			},
			dataType: 'json',
			type: 'post',
			timeout: 10000,
			success: function (res) {
				if (res.code == 2) {
					mui.toast('修改成功!');
					setTimeout(function () {
						mui.openWindow('index.html')
					}, 500)
				} else {
					mui.toast(res.msg);
				}
			}
		});
	})
</script>

</html>